class Posts {
  int id = 0;
  String title = '';
  String author = '';
  String description = '';
  String imageUrl = '';

  // 是否选中
  bool selected = false;

  Posts(this.id, this.title, this.author, this.description, this.imageUrl,
      {this.selected = false});

  // // json转换为实体
  // Posts.fromJson(Map map) {
  //   this.id = map['id'];
  //   this.title = map['title'];
  //   this.author = map['author'];
  //   this.description = map['description'];
  //   this.imageUrl = map['imageUrl'];
  // }
  //
  // // 实体转换为json字符串
  // Map toJson() {
  //   Map map = {};
  //   map['id'] = id;
  //   map['title'] = title;
  //   map['author'] = author;
  //   map['description'] = description;
  //   map['imageUrl'] = imageUrl;
  //   return map;
  // }
  // json转换为实体
  Posts.fromJson(Map map)
      : id = map['id'],
        title = map['title'],
        author = map['author'],
        description = map['description'],
        imageUrl = map['imageUrl'];

  // 实体转换为json字符串
  Map toJson() => {
        'id': id,
        'title': title,
        'author': author,
        'description': description,
        'imageUrl': imageUrl
      };
}
